package c2.cross.business.championrace.handler;

import cate.game.framework.Selector;
import cate.game.pvp.championrace.timer.ChampionRaceTimerTask;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ChampionRaceSettingHandlerSelector implements Selector<AbstractChampionRaceSettingHandler, ChampionRaceTimerTask.Setting>{
    private final List<AbstractChampionRaceSettingHandler> settingHandlers = new ArrayList<>();

    public ChampionRaceSettingHandlerSelector(AbstractChampionRaceSettingHandler... handlers) {
        this.settingHandlers.addAll(Arrays.asList(handlers));
    }

    @Override
    public AbstractChampionRaceSettingHandler select(ChampionRaceTimerTask.Setting setting) {
        return this.settingHandlers.stream()
                .filter(handler -> handler.isMatch(setting))
                .findFirst()
                .orElse(null);
    }

}
